package com.zym.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zym.converter.MyInterConvert;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;
import java.io.Serializable;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@TableName("user")
public class User implements Serializable {
    /**
     * 用户id
     */
    @ExcelIgnore
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 姓名
     */
    @ExcelProperty(value = "姓名", index = 1)
    @NotBlank(message = "姓名不能为空")
    private String name;

    /**
     * 性别
     */
    @ExcelProperty(value = "性别", index = 2, converter = MyInterConvert.class)
    @NotBlank(message = "性别不能为空")
    private String sex;

    /**
     * 年龄
     */
    @ExcelProperty(value = "年龄", index = 3 )
    @Max(value = 60, message = "年龄不能大于60岁")
    @Min(value = 18, message = "年龄不能小于18岁")
    private Integer age;

    /**
     * 手机号码
     */
    @ExcelProperty(value = "手机号码", index = 4)
    @Pattern(regexp = "^[1][3,4,5,7,8][0-9]{9}$", message = "手机号码错误")
    private String phone;

    /**
     * 住址
     */
    @ExcelProperty(value = "家庭住址", index = 5)
    @NotNull(message = "家庭住址不能为null，可以为空")
    private String address;

}
